local klmou__huangtian = fk.CreateSkill({
  name = "klmou__huangtian",
  tags = { Skill.Lord },
  attached_skill_name = "klmou__huangtian_active&",
})

Fk:loadTranslationTable{
  ["klmou__huangtian"] = "黄天",
  [":klmou__huangtian"] = "主公技，其他群势力角色的出牌阶段限一次，其可以交给你一张牌或令你可以选择使用一张牌。",

  ["$klmou__huangtian1"] = "黄衣遍黄土，黄巾应黄天！",
  ["$klmou__huangtian2"] = "着黄衣者，皆是黄天子民！",
}

klmou__huangtian:addAcquireEffect(function (self, player)
  local room = player.room
  for _, p in ipairs(room:getOtherPlayers(player, false)) do
    if p.kingdom == "qun" then
      room:handleAddLoseSkills(p, "klmou__huangtian_active&", nil, false, true)
    else
      room:handleAddLoseSkills(p, "-klmou__huangtian_active&", nil, false, true)
    end
  end
end)

klmou__huangtian:addEffect(fk.AfterPropertyChange, {
  can_refresh = function(self, event, target, player, data)
    return target == player
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    if player.kingdom == "qun" and table.find(room.alive_players, function (p)
      return p ~= player and p:hasSkill(klmou__huangtian.name, true)
    end) then
      room:handleAddLoseSkills(player, "klmou__huangtian_active&", nil, false, true)
    else
      room:handleAddLoseSkills(player, "-klmou__huangtian_active&", nil, false, true)
    end
  end,
})

return klmou__huangtian
